<?php
/**
 * 
 */
 
 function checkExchangeYearFolder() {
 	$path = 'I:/www/apache2/htdocs/jobb/files/' . getYear();
 	return is_dir($path);
 } 
 
 function createExchangeYearFolder() {
 	$path = 'I:/www/apache2/htdocs/jobb/files/';
 	if(is_writable($path)) {
 		mkdir($path . getYear(), 0777);
 	} else {
 		echo("The directory is not writeable");
 	}
 }
 
 function checkUserFolder($username) {
 	$path = 'I:/www/apache2/htdocs/jobb/files/' . getYear() . '/';
 	return is_dir($path . $username);
 }
 
 function createUserFolder($username) {
 	$path = 'I:/www/apache2/htdocs/jobb/files/' . getYear() . '/';
 	if(is_writable($path)) {
 		mkdir($path . $username);
 	} else {
 		echo("Folder is not writeable");
 	}
 }
 
 function uploadUserFile($username, $file) {
 	$path = 'I:/www/apache2/htdocs/jobb/files/' . getYear() . '/' . $username . '/';
 	$uploadfile = $path . basename($_FILES[$file]["name"]);
 	if(move_uploaded_file($_FILES[$file]['tmp_name'], $uploadfile)) {
 		echo "File is uploaded.";
 	} else {
 		echo "File not uploaded.";
 	}
 }
 
 function uploadUserFiles($username, $files) {
 	$path = 'I:/www/apache2/htdocs/jobb/files/' . getYear() . '/' . $username . '/';
 	foreach($_FILES[""]["error"] as $key => $error) {
 		$tmp_name = $FILES[""]["tmp_name"][$key];
 		$name = $_FILES[""]["name"][$key];
 		move_uploaded_file($tmp_name, $path . $name);
 	}
 }
 
?>